<template>
    <div class="studentList">
        <el-table :data="dataList"  border style="width: 100%">
            <el-table-column prop="bussinessAccountName" label="账号" align="center">
            </el-table-column>
            <el-table-column prop="bussinessCode" label="编号" align="center">
            </el-table-column>
            <el-table-column prop="bussinessName" label="店铺名" align="center">
            </el-table-column>
            <el-table-column prop="linkMan" label="联系人" align="center">
            </el-table-column>
            <el-table-column prop="phoneNumber" label="联系方式" align="center">
        </el-table-column>
            <el-table-column prop="bankName" label="开户行" align="center">
            </el-table-column>
            <el-table-column prop="bankAccount" label="银行卡号" align="center">
            </el-table-column>
            <el-table-column prop="state_text" label="状态" align="center">
            </el-table-column>
            <el-table-column label="是否批准" align="center">
                <template slot-scope="scope">
                    <el-button
                            type="success"
                            size="mini"
                            icon="el-icon-check"
                            @click="setY(scope.row)"
                    ></el-button>
                    <el-button
                            type="danger"
                            size="mini"
                            icon="el-icon-close"
                            @click="setN(scope.row)"
                    ></el-button>
                </template>
            </el-table-column>
        </el-table>
        <el-pagination
                class="pagiantion"
                @current-change="handleCurrentChange"
                :current-page="pagination.currentPage"
                :page-size="pagination.pageSize"
                layout="total, prev, pager, next, jumper"
                :total="pagination.total"
        >
        </el-pagination>
    </div>
</template>
<script>
    import {getBussData} from "../../../api/api";
    import {setBussStatus} from "../../../api/api";

    export default {
        data() {
            return {
                dataList: [
                ],
                pagination:{
                    currentPage: 1, //当前页数
                    pageSize: 10, // 每页显示条数
                    total: 0, // 总条数
                    status:0
                },

                formInline: {
                    name: "",
                },
            };
        },
        created() {
            this.getData();
        },
        computed: {

        },
        methods: {
            handleCurrentChange(currentPage) {
                //修改页码值为当前选中的页码值
                this.pagination.currentPage = currentPage;
                //执行查询
                this.getData();
            },
            getData() {
                getBussData(this.pagination).then((res) => {
                    if (res.data.status === 200) {
                    console.log(res.data)
                        this.dataList = res.data.data.records;
                       this.pagination.total = res.data.data.total;

                        this.dataList.forEach((item) => {
                            // 尽量不要修改原数据
                            item.bussinessApplicationStatus == "0"
                                ? (item.state_text = "正在申请")
                                : item.state === "1"
                                ? (item.state_text = "申请成功")
                                : (item.state_text = "申请失败");
                        });
                    }
                });
            },
            setY(row) {
                row.bussinessApplicationStatus="1";
                setBussStatus(row).then((res) => {
                    if (res.data.status === 200) {
                        this.getData();
                    }
                });
            },
            setN(row) {
                row.bussinessApplicationStatus="2";
                setBussStatus(row).then((res) => {
                    if (res.data.status === 200) {
                        this.getData();
                    }
                });
            },
        },
    };
</script>
<style lang="scss">
    .studentList {
        .demo-form-inline,.el-form-item {
            text-align: left;
        }
        .el-pagination {
            text-align: left;
            margin-top: 20px;
        }
    }
</style>
